#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

struct ListNode {
    int val;
    struct ListNode* next;
};

struct ListNode* getIntersectionNode(struct ListNode* headA, struct ListNode* headB)
{
    struct ListNode* tailA = headA;
    struct ListNode* tailB = headB;
    int lenA = 1, lenB = 1;
    while (tailA->next)
    {
        ++lenA;
        tailA = tailA->next;
    }
    while (tailB->next)
    {
        ++lenB;
        tailB = tailB->next;
    }
    if (tailA != tailB)
    {
        return NULL;
    }
    int gap = abs(lenA - lenB);
    struct ListNode* longList = headA;
    struct ListNode* shortList = headB;
    if (lenA < lenB)
    {
        struct ListNode* longList = headB;
        struct ListNode* shortList = headA;
    }
    while (gap--)
    {
        longList = longList->next;
    }
    while (longList != shortList)
    {
        shortList = shortList->next;
        longList = longList->next;
    }
    return longList;
}

int main()
{

	return 0;
}